//
//  SAStatisticsBusinessCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/7/22.
//

#import "SAStatisticsBusinessCell.h"
#import "SAStatisticsBusinessModel.h"

@interface SAStatisticsBusinessCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *titleLab1;

@property (nonatomic, strong) UILabel *titleLab2;
@property (nonatomic, strong) UILabel *titleLab3;

@property (nonatomic, strong) UILabel *titleLab4;
@property (nonatomic, strong) UILabel *titleLab5;

@end

@implementation SAStatisticsBusinessCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAStatisticsBusinessModel *)model {
    _model = model;
    self.titleLab.text = [NSString stringWithFormat:@"现金:%0.2lf",[model.xj doubleValue]/100];
    self.titleLab1.text = [NSString stringWithFormat:@"刷卡:%0.2lf",[model.sk doubleValue]/100];
    self.titleLab2.text = [NSString stringWithFormat:@"微信:%0.2lf",[model.wx doubleValue]/100];
    self.titleLab3.text = [NSString stringWithFormat:@"支付宝:%0.2lf",[model.zfb doubleValue]/100];
    
    self.titleLab5.text = @"";
    if ([model.titleName isEqualToString:@"销售"]) {
        self.titleLab4.text = [NSString stringWithFormat:@"余额:%0.2lf",[model.ye doubleValue]/100];
        self.titleLab5.text = [NSString stringWithFormat:@"扫码:%0.2lf",[model.sm doubleValue]/100];
    }else if ([model.titleName isEqualToString:@"退货"]) {
        self.titleLab4.text = [NSString stringWithFormat:@"余额:%0.2lf",[model.ye doubleValue]/100];
    }else if ([model.titleName isEqualToString:@"充值"]) {
        self.titleLab4.text = [NSString stringWithFormat:@"扫码:%0.2lf",[model.sm doubleValue]/100];
    }
}

-(void)initUI {
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.titleLab1];
    [self.contentView addSubview:self.titleLab2];
    [self.contentView addSubview:self.titleLab3];
    [self.contentView addSubview:self.titleLab4];
    [self.contentView addSubview:self.titleLab5];
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(5, 5, 115, 20)];
        _titleLab.textColor = kLightgGrayColor;
        _titleLab.textAlignment = NSTextAlignmentLeft;
        _titleLab.font = kFont(15);
        _titleLab.adjustsFontSizeToFitWidth = YES;
        _titleLab.minimumScaleFactor = 0.8;
    }
    return _titleLab;
}

-(UILabel *)titleLab1 {
    if (!_titleLab1) {
        _titleLab1 = [[UILabel alloc] initWithFrame:SARectMake(130, 5, 115, 20)];
        _titleLab1.textColor = kLightgGrayColor;
        _titleLab1.textAlignment = NSTextAlignmentLeft;
        _titleLab1.font = kFont(15);
        _titleLab1.adjustsFontSizeToFitWidth = YES;
        _titleLab1.minimumScaleFactor = 0.8;
    }
    return _titleLab1;
}

-(UILabel *)titleLab2 {
    if (!_titleLab2) {
        _titleLab2 = [[UILabel alloc] initWithFrame:SARectMake(255, 5, 115, 20)];
        _titleLab2.textColor = kLightgGrayColor;
        _titleLab2.textAlignment = NSTextAlignmentLeft;
        _titleLab2.font = kFont(15);
        _titleLab2.adjustsFontSizeToFitWidth = YES;
        _titleLab2.minimumScaleFactor = 0.8;
    }
    return _titleLab2;
}

-(UILabel *)titleLab3 {
    if (!_titleLab3) {
        _titleLab3 = [[UILabel alloc] initWithFrame:SARectMake(5, 30, 115, 20)];
        _titleLab3.textColor = kLightgGrayColor;
        _titleLab3.textAlignment = NSTextAlignmentLeft;
        _titleLab3.font = kFont(15);
        _titleLab3.adjustsFontSizeToFitWidth = YES;
        _titleLab3.minimumScaleFactor = 0.8;
    }
    return _titleLab3;
}

-(UILabel *)titleLab4 {
    if (!_titleLab4) {
        _titleLab4 = [[UILabel alloc] initWithFrame:SARectMake(130, 30, 115, 20)];
        _titleLab4.textColor = kLightgGrayColor;
        _titleLab4.textAlignment = NSTextAlignmentLeft;
        _titleLab4.font = kFont(15);
        _titleLab4.adjustsFontSizeToFitWidth = YES;
        _titleLab4.minimumScaleFactor = 0.8;
    }
    return _titleLab4;
}

-(UILabel *)titleLab5 {
    if (!_titleLab5) {
        _titleLab5 = [[UILabel alloc] initWithFrame:SARectMake(255, 30, 115, 20)];
        _titleLab5.textColor = kLightgGrayColor;
        _titleLab5.textAlignment = NSTextAlignmentLeft;
        _titleLab5.font = kFont(15);
        _titleLab5.adjustsFontSizeToFitWidth = YES;
        _titleLab5.minimumScaleFactor = 0.8;
    }
    return _titleLab5;
}

@end
